import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { View, Text } from 'react-native'
import { Modal} from 'antd-mobile'
import Scan from './Scan'

export default class extends Component {
  static propTypes: {
    hide: PropTypes.func,
    visible: PropTypes.bool,
    onSuccess: PropTypes.func
  }
  constructor(props) {
    super(props)
  }
  render() {
    return (
      <Modal
        title="这是 title"
        transparent
        maskClosable={false}
        visible={this.props.visible}
        onClose={this.onClose}
        footer={[{ text: '取消', onPress: () => {}}]}
      >
        <View style={{height: 400}}>
          <Scan onBarcodeReveived={this.onBarcodeReveived}/>
        </View>
      </Modal>
    )
  }

  onBarcodeReveived = (value) => {
    this.props.onSuccess(value)
  }

  onClose = () => {
    this.props.hide()
  }
}
